package complexite;

import java.util.ArrayList;
import java.util.Collections;


public class Qsort {


//-Xms512m  -Xmx1024m augementer la mémoire virtuelle java ;) 
public static void sort (ExtArrayList az) {
	try{
	Collections.sort(az);
	}catch (OutOfMemoryError e){
		System.out.println("Dépassement mémoire programme stoppé");
	}
}


public static void main (String args[]){
	
	ArrayList<Long> moy = new ArrayList<Long>();
	
	for(int i = 0 ; i < 5 ; i++){
		
		ExtArrayList az=new ExtArrayList();
		az.getArray(1000001, 1000, 60000);
		long deb = System.currentTimeMillis();
    	sort(az);
    	moy.add(System.currentTimeMillis() - deb);
	}
	
	long total = 0;
	for (Long long1 : moy) {
		total += long1;
	}
	
	System.out.println(total / moy.size());
}



}
